package waitandnotify02;

import java.lang.reflect.Array;
import java.util.concurrent.ArrayBlockingQueue;

public class Producer extends Thread{
    private ArrayBlockingQueue<String> queue;
    public Producer(String name, ArrayBlockingQueue<String> queue){
        super(name);
        this.queue = queue;
    }

    @Override
    public void run() {
        while (true) {
            try {
                // 1.不断的把面条放到阻塞队列当中
                queue.put("面条"); // put方法底层源码就已经使用了Lock锁
                System.out.println(getName()+"放了一个面条");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
